package xyx.ysfwpt.service;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import xyx.ysfwpt.dao.OrderDao;
import xyx.ysfwpt.model.Order;
import xyx.ysfwpt.model.OrderDetail;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("OrderService")
public class OrderServiceImpl implements OrderService{
    @Resource
    OrderDao orderDao;

    @Override
    public List<Order> selectAllOrder(){
        return orderDao.selectAllOrder();
    }

    public List<Order> selectOrderByInputList(@Param(value = "user_id") int user_id,
                                              @Param(value = "user_type") String user_type,
                                              @Param(value = "hospital") String hospital,
                                              @Param(value = "user_department") String user_department,
                                              @Param(value = "state") Integer state,
                                              @Param(value = "source") String source,
                                              @Param(value = "type") Integer type,
                                              @Param(value = "searchword") String searchword,
                                              @Param(value = "timefrom") String timefrom,
                                              @Param(value = "timeto") String timeto,
                                              @Param(value = "isDirector") String isDirector,
                                              @Param(value = "department") String department){
        return orderDao.selectOrderByInputList(user_id,user_type,hospital,user_department,state,source,type,searchword,timefrom,timeto,isDirector,department);
    }

    public  List<OrderDetail>  selectMedicineByOrderId(String order_id){
        return orderDao.selectMedicineByOrderId(order_id);
    }

    public Order selectOrderDetailByOrderId(String order_id){
        return orderDao.selectOrderDetailByOrderId(order_id);
    }

    public void updateOrderState(@Param(value = "order_id") String order_id,
                                 @Param(value = "state") Integer state,
                                 @Param(value = "reason_name") String reason_name,
                                 @Param(value = "reason") String reason){
        orderDao.updateOrderState(order_id,state,reason_name,reason);
    }

    public void updateOrderExpress(@Param(value = "order_id") String order_id,
                                   @Param(value = "express_company_name") String express_company_name,
                                   @Param(value = "express_price") float express_price,
                                   @Param(value = "express_id") String express_id){
        orderDao.updateOrderExpress(order_id,express_company_name,express_price,express_id);
    }

    public List<Map> selectOrderAmountByYear(@Param(value = "yearfrom") String yearfrom,
                                             @Param(value = "yearto") String yearto,
                                             @Param(value = "type") String type){
        return orderDao.selectOrderAmountByYear(yearfrom,yearto,type);
    }

    public Map selectOrderAmountAndMoney1(@Param(value = "timefrom") String timefrom,
                                          @Param(value = "timeto") String timeto){
        return orderDao.selectOrderAmountAndMoney1(timefrom,timeto);
    }

    public Map selectOrderAmountAndMoney2(@Param(value = "timefrom") String timefrom,
                                          @Param(value = "timeto") String timeto){
        return orderDao.selectOrderAmountAndMoney2(timefrom,timeto);
    }

    public List<Map> selectOrderByDay0(@Param(value = "timefrom") String timefrom,
                                       @Param(value = "timeto") String timeto){
        return orderDao.selectOrderByDay0(timefrom,timeto);
    }

    public List<Map> selectOrderByDay1(@Param(value = "timefrom") String timefrom,
                                       @Param(value = "timeto") String timeto){
        return orderDao.selectOrderByDay1(timefrom,timeto);
    }

    public List<Map> selectOrderByDay2(@Param(value = "timefrom") String timefrom,
                                       @Param(value = "timeto") String timeto){
        return orderDao.selectOrderByDay2(timefrom,timeto);
    }

}
